<include file="public/layout" />
<script src="__ROOT__/static/js/layer/laydate/laydate.js"></script>
<style>
    ul.group-list {
        width: 96%;min-width: 1000px; margin: auto 5px;list-style: disc outside none;
    }
    .err{color:#F00; display:none;}
    ul.group-list li {
        white-space: nowrap;float: left;
        width: 150px; height: 25px;
        padding: 3px 5px;list-style-type: none;
        list-style-position: outside;border: 0px;margin: 0px;
    }
    .row .table-bordered td .btn,.row .table-bordered td img{
        vertical-align: middle;
    }
    .row .table-bordered td{
        padding: 8px;
        line-height: 1.42857143;
    }
    .table-bordered{
        width: 100%
    }
    .table-bordered tr td{
        border: 1px solid #f4f4f4;
    }
    .btn-success {
        color: #fff;background-color: #449d44;border-color: #398439 solid 1px;
    }
    .btn {
        display: inline-block;
        padding: 6px 12px;
        margin-bottom: 0;
        font-size: 14px;
        font-weight: 400;
        line-height: 1.42857143;
        text-align: center;
        white-space: nowrap;
        vertical-align: middle;
        -ms-touch-action: manipulation;
        touch-action: manipulation;
        cursor: pointer;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        background-image: none;
        border: 1px solid transparent;
        border-radius: 4px;
    }
    .col-xs-8 {
        width: 66.66666667%;
    }
    .col-xs-4 {
        width: 33.33333333%;
    }
    .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 {
        float: left;
    }
    .row .tab-pane h4{
        padding: 10px 0;
    }
    .row .tab-pane h4 input{
        vertical-align: middle;
    }
    .table-striped>tbody>tr:nth-of-type(odd) {
        background-color: #f9f9f9;
    }
    .ncap-form-default .title{
        border-bottom: 0
    }
    .ncap-form-default dl.row, .ncap-form-all dd.opt{
        /*border-color: #F0F0F0;*/
        border: none;
    }
    .ncap-form-default dl.row:hover, .ncap-form-all dd.opt:hover{
        border: none;box-shadow: inherit;
    }
    .addprine{display: inline; }
    .alisth{margin-top: 10px}
    .p_plus strong{cursor: pointer;margin-left: 4px;}
</style>
<!--物流配置 css -end-->
<!--以下是在线编辑器 代码 -->
<load href="__ROOT__/plugins/Ueditor/ueditor.config.js"/>
<load href="__ROOT__/plugins/Ueditor/ueditor.all.min.js"/>
<script type="text/javascript" charset="utf-8" src="__ROOT__/plugins/Ueditor/lang/zh-cn/zh-cn.js"></script>
<!--以上是在线编辑器 代码  end-->
<body style="background-color: #FFF; overflow: auto;">
<!--<div id="append_parent"></div>-->
<!--<div id="ajaxwaitid"></div>-->

<div class="page">
    <div class="">
        <div class="item-title">
            <div class="subject">
                <h3>设施设置</h3>
            </div>
            <ul class="tab-base nc-row">
                <li><a href="javascript:void(0);" data-index='1' class="tab current"><span>通用信息</span></a></li>
                <li><a href="javascript:void(0);" data-index='2' class="tab"><span>设施相册</span></a></li>
            </ul>
        </div>
    </div>
    <!-- 操作说明 -->
    <div class="explanation" id="explanation">
        <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span id="explanationZoom" title="收起提示"></span> </div>
        <ul>
            <li>请务必正确填写设施信息</li>
            <li>商品相册的图片最佳比列为 宽*高 800x525 </li>
            <li>上传单张图片不超过2M </li>
        </ul>
    </div>
    <!--表单数据-->
    <form method="post" id="edit_build">
        <!--<input type="hidden" value="{$Request.param.is_distribut}" name="is_distribut" class="input-txt"/>-->
        <!--通用信息-->
        <div class="ncap-form-default tab_div_1">
            <dl class="row">
                <dt class="tit">
                    <label for="record_no">设施名称</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$builds.names}" name="names" class="input-txt"/>
                    <span class="err" id="err_names" style="color:#F00; display:none;"></span>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="store_name">设施简介</label>
                </dt>
                <dd class="opt">
                    <textarea rows="3" cols="80" name="remark" class="input-txt">{$builds.remark}</textarea>
                    <span id="err_remark" class="err" style="color:#F00; display:none;"></span>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">设施大类</label>
                </dt>
                <dd class="opt">
                    <select name="big_type" id="big_type"  class="small form-control">
                        <option value="0">请选择设施大类</option>
                        <foreach name="big_types" item="v" key="k" >
                            <option value="{$v['id']}" <if condition="$v['id'] eq $builds.big_type">selected="selected"</if> >
                            {$v['names']}
                            </option>
                        </foreach>
                    </select>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">设施分类</label>
                </dt>
                <dd class="opt">
                    <select name="build_type" id="build_type"  class="small form-control">
                        <option value="0">请选择设施分类</option>
                        <foreach name="build_types" item="v" key="k" >
                            <option value="{$v['id']}" <if condition="$v['id'] eq $builds.build_type">selected="selected"</if> >
                            {$v['type_name']}
                            </option>
                        </foreach>
                    </select>
                    <span class="err" id="err_build_types" style="color:#F00; display:none;"></span>
                </dd>
            </dl>


            <dl class="row">
                <dt class="tit">
                    <label for="record_no">设施区域</label>
                </dt>
                <dd class="opt">
                    <select name="region_id" id="region_id"  class="small form-control">
                        <option value="">所有区域</option>
                        <foreach name="regions" item="v" key="k" >
                            <option value="{$v['id']}"  <if condition="$v['id'] eq $builds['region_id'] ">selected="selected"</if>>
                            {$v['region']}
                            </option>
                        </foreach>
                    </select>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">联系人</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$builds.contact_name}" name="contact_name" class="t_mane" />
                    <span class="err" id="err_contact_name" style="color:#F00; display:none;"></span>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">联系电话</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$builds.contact_phone|default=0}" name="contact_phone" class="t_mane" />
                    <span class="err" id="err_contact_phone" style="color:#F00; display:none;"></span>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">设施地址</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$builds.address}" name="address" class="t_mane" />
                    <span class="err" id="err_address" style="color:#F00; display:none;"></span>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">经度</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$builds.longitude}" name="longitude" class="t_mane" />
                    <span class="err" id="err_longitude" style="color:#F00; display:none;"></span>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">纬度</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$builds.latitude}" name="latitude" class="t_mane" />
                    <span class="err" id="err_latitude" style="color:#F00; display:none;"></span>
                </dd>
            </dl>


            <dl class="row">
                <dt class="tit">
                    <label>图片上传</label>
                </dt>
                <dd class="opt">
                    <div class="input-file-show">
            <span class="show">
                <a id="img_a" target="_blank" class="nyroModal" rel="gal" href="{$builds.icon}">
                    <i id="img_i" class="fa fa-picture-o" onMouseOver="layer.tips('<img src={$builds.icon}>',this,{tips: [1, '#fff']});" onMouseOut="layer.closeAll();"></i>
                </a>
            </span>
                        <span class="type-file-box">
                <input type="text" id="imagetext" name="icon" value="{$builds.icon}" class="type-file-text">
                <input type="button" name="button" id="button1" value="选择上传" class="type-file-button">
                <input class="type-file-file" onClick="GetUploadify(1,'','builds','img_call_back')" size="30" hidefocus="true" nc_type="change_site_logo" title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
            </span>
                    </div>
                    <span class="err"></span>
                    <p class="notic">请上传图片格式文件 最佳尺寸1:1 </p>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">商品详情描述</label>
                </dt>
                <dd class="opt">
                    <textarea class="span12 ckeditor" id="desc" name="desc" title="">{$builds.desc}</textarea>
                    <span class="err" id="err_desc" style="color:#F00; display:none;"></span>
                </dd>
            </dl>
        </div>
        <!--通用信息-->
        <!-- 设施相册-->
        <div class="ncap-form-default tab_div_2" style="display:none;">
            <dl class="row">
                <div class="tab-pane" id="tab_goods_images">
                    <table class="table table-bordered">
                        <tbody>
                        <tr>
                            <td>
                                <foreach name="buildsImages" item="vo" key="k" >
                                    <div style="width:100px; text-align:center; margin: 5px; display:inline-block;" class="goods_xc">
                                        <input type="hidden" value="{$vo['urls']}" name="builds_images[]">
                                        <a onClick="" href="{$vo['urls']}" target="_blank"><img width="100" height="100" src="{$vo['urls']}"></a>
                                        <br>
                                        <a href="javascript:void(0)" onClick="ClearPicArr2(this,'{$vo['urls']}')">删除</a>
                                    </div>
                                </foreach>

                                <div class="goods_xc" style="width:100px; text-align:center; margin: 5px; display:inline-block;">
                                    <input type="hidden" name="builds_images[]" value="" />
                                    <a href="javascript:void(0);" onClick="GetUploadify(10,'','builds','call_back2');"><img src="/images/add-button.jpg" width="100" height="100" /></a>
                                    <br/>
                                    <a href="javascript:void(0)">&nbsp;&nbsp;</a>
                                </div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </dl>
        </div>
        <!-- 商品相册-->

        <div class="ncap-form-default">
            <div class="bot">
                <input type="hidden" name="id" value="{$builds.id}">
                <input type="hidden" name="__token__" value="{$Request.token}" />
                <a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" onClick="ajax_submit_form('edit_build','{:U('Builds/edit_build?is_ajax=1')}');">确认提交</a>
            </div>
        </div>
    </form>

    <!--表单数据-->
</div>
<div id="goTop"> <a href="JavaScript:void(0);" id="btntop"><i class="fa fa-angle-up"></i></a><a href="JavaScript:void(0);" id="btnbottom"><i class="fa fa-angle-down"></i></a></div>
<script>

    $(function(){
        $(document).on("click",'.is_virtual',function(){
            initIsVirtual();
        })
    })


    var url="{:url('Admin/Ueditor/index',array('savePath'=>'builds'),false)}";
    // var url= "Admin/Ueditor/index/savePath/builds/";//"{:url('Admin/Ueditor/index/savePath/builds')}";
    var ue = UE.getEditor('desc',{
        serverUrl :url,
        zIndex: 999,
        initialFrameWidth: "100%", //初化宽度
        initialFrameHeight: 300, //初化高度
        focus: false, //初始化时，是否让编辑器获得焦点true或false
        maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
        pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
        autoHeightEnabled: true
    });


    /*
     * 以下是图片上传方法
     */
    // 上传商品图片成功回调函数
    function call_back(fileurl_tmp){
        $("#original_img").val(fileurl_tmp);
        $("#original_img2").attr('href', fileurl_tmp);
    }

    // 上传商品相册回调函数
    function call_back2(paths){

        var  last_div = $(".goods_xc:last").prop("outerHTML");
        for (var i=0;i<paths.length ;i++ )
        {
            $(".goods_xc:eq(0)").before(last_div);	// 插入一个 新图片
            $(".goods_xc:eq(0)").find('a:eq(0)').attr('href',paths[i]).attr('onclick','').attr('target', "_blank");// 修改他的链接地址
            $(".goods_xc:eq(0)").find('img').attr('src',paths[i]);// 修改他的图片路径
            $(".goods_xc:eq(0)").find('a:eq(1)').attr('onclick',"ClearPicArr2(this,'"+paths[i]+"')").text('删除');
            $(".goods_xc:eq(0)").find('input').val(paths[i]); // 设置隐藏域 要提交的值
        }
    }
    /*
     * 上传之后删除组图input
     * @access   public
     * @val      string  删除的图片input
     */
    function ClearPicArr2(obj,path)
    {
        $.ajax({
            type:'GET',
            url:"{:U('Admin/Uploadify/delupload')}",
            data:{action:"del", filename:path},
            success:function(){
                $(obj).parent().remove(); // 删除完服务器的, 再删除 html上的图片
            }
        });
        // 删除数据库记录
        $.ajax({
            type:'GET',
            url:"{:U('Admin/Builds/del_build')}",
            data:{filename:path},
            success:function(){
                //
            }
        });
    }


    $(document).ready(function(){
        //插件切换列表
        $('.tab-base').find('.tab').click(function(){
            $('.tab-base').find('.tab').each(function(){
                $(this).removeClass('current');
            });
            $(this).addClass('current');
            var tab_index = $(this).data('index');
            $(".tab_div_1, .tab_div_2, .tab_div_3, .tab_div_4,.tab_div_5").hide();
            $(".tab_div_"+tab_index).show();
        });

    });

    function img_call_back(fileurl_tmp)
    {
        // console.log('fileurl_tmp='+fileurl_tmp);
        $("#imagetext").val(fileurl_tmp);
        $("#img_a").attr('href', fileurl_tmp);
        $("#img_i").attr('onmouseover', "layer.tips('<img src="+fileurl_tmp+">',this,{tips: [1, '#fff']});");
    }



</script>
</body>
</html>